<template>
	<view class="content">
		<view class="tips-item">
			<view class="tip iconfont icon-gantanhao">
				<text class="txt">提示：所填写的内容和所提供的材料真实准确，如有虚报冒领等行为，将承担相应的法律责任并接受相关处罚。</text>
			</view>
		</view>
		<view class="info-block">
			<view class="title FangZhengHanZhenGuangBiaoJianTi">申请信息</view>
			<view class="form-item">
				<view style="display: flex;flex-direction: row;">
					<view style="color: #C10A11;">*</view>
					<view class="form-label">申请金额 (万元)</view>
				</view>
				<view class="form-content">
					<input v-model="form.money" maxlength="10" type="number" placeholder="请填写申请金额"
						placeholder-class="inputPlaceholder" class="form-ctrl" placeholder-style="color:#000;" />
				</view>
			</view>
			<view class="form-item">
				<view style="display: flex;flex-direction: row;">
					<view style="color: #C10A11;">*</view>
					<view class="form-label">申请期限 (月)</view>
				</view>
				<view class="form-content">
					<input v-model="form.month" maxlength="10" type="number" placeholder="请填写申请期限"
						placeholder-class="inputPlaceholder" class="form-ctrl" placeholder-style="color:#000;" />
				</view>
			</view>
			<view class="form-item">
				<view style="display: flex;flex-direction: row;">
					<view style="color: #C10A11;">*</view>
					<view class="form-label">贷款用途</view>
				</view>
				<view class="form-content">
					<picker :range="useType" range-key="value" @change="bindType" class="form-ctrl"
						:value="form.useIndex">
						{{form.useIndex==-1 ? "请选择贷款用途" : useType[form.useIndex]['value']}}
					</picker>
					<view class="iconfont icon-gengduo1 arrow"></view>
				</view>
			</view>
			<view class="form-item">
				<view style="display: flex;flex-direction: row;">
					<view style="color: #C10A11;">*</view>
					<view class="form-label">是否需担保公司担保</view>
				</view>
				<view class="form-content">
					<picker :range="security" range-key="value" @change="bindSecurity" class="form-ctrl"
						:value="form.securityIndex">
						{{form.securityIndex==-1 ? "请选择婚姻状态" : security[form.securityIndex]['value']}}
					</picker>
					<view class="iconfont icon-gengduo1 arrow"></view>
				</view>
			</view>
		</view>
		<view style="display: flex;flex-direction: row;">
			<view class="btn1" @click="goBack">上一步</view>
			<view class="btn" @click="handleSave">下一步</view>
		</view>
	</view>
</template>

<script>
	import {
		validate
	} from '@/util/validate.js'
	export default {
		data() {
			return {
				id: null,
				form: {
					money: '',
					month: '',
					useIndex: -1,
					securityIndex: -1,
				},
				rules: {
					money: {
						name: '申请金额',
						required: true
					},
					month: {
						name: '申请期限',
						required: true
					},

					securityIndex: {
						name: '是否需担保公司担保',
						required: true,
						validator: function(value, form, callback) {
							if (value < 0) {
								callback('请选择是否需担保公司担保')
							}
							callback();
						}
					},
					useIndex: {
						name: '贷款用途',
						required: true,
						validator: function(value, form, callback) {
							if (value < 0) {
								callback('请选择贷款用途')
							}
							callback();
						}
					},

				},
				useType: [{
					id: 1,
					value: '创业'
				}],
				security: [{
						id: 1,
						value: '是'
					},
					{
						id: 2,
						value: '否'
					}
				],
			}
		},
		methods: {
			bindType(e) {
				this.form.useIndex = e.detail.value;
			},
			bindSecurity(e) {
				this.form.securityIndex = e.detail.value;
			},
			goBack() {
				uni.redirectTo({
					url: '/page_other/business_loan/business_loan'
				})
			},
			handleSave() {
				if (validate(this.form, this.rules)) {
					uni.redirectTo({
						url: '/page_other/business_loan/entrepreneurship_information'
					})
				}
			}
		}
	}
</script>

<style lang="scss">
	.content {
		width: 100%;
		padding: 30rpx;

		.tips-item {
			display: flex;
			flex-direction: column;
			color: #F4982B;
			background: #FFF0D6;
			padding: 20rpx;
			border-radius: 20rpx;

			.tips {
				width: 100%;
				display: flex;
				align-items: center;
				padding: 20rpx;
				font-size: 24rpx;
			}

			.iconfont {
				font-size: 14px;

				.txt {
					margin-left: 16rpx;
					font-size: 14px;
					line-height: 50rpx;
				}
			}
		}

		.info-block {
			margin-top: 30rpx;
			background: #fff;
			border-radius: 20rpx;
			padding: 20rpx;

			.title {
				margin-top: 30rpx;
				font-size: 38rpx;
			}

			.form-item {
				display: flex;
				flex-direction: column;
				border-bottom: 1px solid #efefef;
				padding-top: 30rpx;

				.form-label {
					font-size: 28rpx;
					color: #999;
				}

				.form-content {
					display: flex;
					flex-direction: row;
					align-items: center;

					.form-ctrl {
						height: 100rpx;
						line-height: 100rpx;
						flex-grow: 1;
					}

					.arrow {
						flex-grow: 0;
						color: #999;
						font-size: 24rpx;
					}
				}
			}
		}

		.btn1 {
			width: 290rpx;
			height: 90rpx;
			display: flex;
			justify-content: center;
			align-items: center;
			border: 1px solid #FF0015;
			color: #FF0015;
			font-size: 28rpx;
			border-radius: 50rpx;
			margin: 0 auto;
			margin-top: 30rpx;
		}

		.btn {
			width: 290rpx;
			height: 90rpx;
			display: flex;
			justify-content: center;
			align-items: center;
			background: #FF0015;
			color: #fff;
			font-size: 28rpx;
			border-radius: 50rpx;
			margin: 0 auto;
			margin-top: 30rpx;
		}
	}
</style>